package com.stylefeng.guns.rest.modular.wz.controller;

import com.stylefeng.guns.rest.common.persistence.dao.WzAdvMapper;
import com.stylefeng.guns.rest.common.persistence.dao.WzAdvUserMapper;
import com.stylefeng.guns.rest.common.persistence.dao.WzQuestionnaireMapper;
import com.stylefeng.guns.rest.common.persistence.model.WzAdv;
import com.stylefeng.guns.rest.common.persistence.model.WzAdvUser;
import com.stylefeng.guns.rest.common.persistence.model.WzQuestionnaire;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class AsyncSaveService {
    @Autowired
    private WzAdvUserMapper advUserMapper;
    @Autowired
    private WzQuestionnaireMapper questionnaireMapper;
    @Autowired
    private WzAdvMapper advMapper;
    /**
     * 保存新用户问卷
     */
    @Transactional
    public boolean saveAdvQue(WzAdvUser advUser, WzQuestionnaire questionnaire) {
        int r = advUserMapper.insert(advUser);
        if(r > 0){
            r = questionnaireMapper.updateById(questionnaire);
            if(r > 0){
                return true;
            }
        }
        return false;
    }

}
